package com.fadadianqi.logistics.customer.dao.ibatis;

import com.fadadianqi.commons.GenericDAOSuport;
import com.fadadianqi.logistics.customer.dao.TownDAO;
import com.fadadianqi.logistics.customer.model.Town;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class TownDAOImpl extends GenericDAOSuport<String, Town> implements
        TownDAO {

    @Override
    protected Class<?> getObjectClass() {
        return Town.class;
    }

    @Override
    protected String getTableName() {
        return "town";
    }

    @Override
    public Town getByName(String name) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put(Town.PROP_NAME, name);
        return super.getByPropertys(map);
    }

    @Override
    public List<Town> findAll() {
        return super.findAll(null);
    }

}
